import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-pipe-practice',
  templateUrl: './pipe-practice.component.html',
  styleUrls: ['./pipe-practice.component.less']
})
export class PipePracticeComponent implements OnInit {

  money: any;

  constructor() { }

  onKeyUp($event) {
    let moneyStr: string;
    let firstNum: string;
    let secondNum: string;
    if (this.money) {
      moneyStr = this.money.toString();
      if (moneyStr.length > 1) {
        firstNum = moneyStr.substr(0, 1);
        secondNum = moneyStr.substr(1, 1);
        if (firstNum === '0') {
          if (secondNum !== '.') {
            this.money = parseInt(firstNum, 0);
          }
        }
      }
    }
  }

  ngOnInit() {
  }

}
